import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { TopicForm, TopicOptions, TopicPage, TopicQuery } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getTopicPage(
  queryParams: TopicQuery
): AxiosPromise<PageResult<TopicPage[]>> {
  return request({
    url: "/admin/examTopic/index",
    method: "get",
    params: queryParams,
  });
}

export function getOptions(): AxiosPromise<TopicOptions[]> {
  return request({
    url: "/admin/examTopic/getOptions",
    method: "get",
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getTopicForm(ids: number): AxiosPromise<TopicForm> {
  return request({
    url: "/admin/examTopic/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addTopic(data: any) {
  return request({
    url: "/admin/examTopic/add",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateTopic(data: TopicForm) {
  return request({
    url: "/admin/examTopic/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteTopic(data: any) {
  return request({
    url: "/admin/examTopic/del",
    method: "delete",
    data,
  });
}
